--       _________ __                 __                               
--      /   _____//  |_____________ _/  |______     ____  __ __  ______
--      \_____  \\   __\_  __ \__  \\   __\__  \   / ___\|  |  \/  ___/
--      /        \|  |  |  | \// __ \|  |  / __ \_/ /_/  >  |  /\___ \ 
--     /_______  /|__|  |__|  (____  /__| (____  /\___  /|____//____  >
--             \/                  \/          \//_____/            \/ 
--  ______________________                           ______________________
--			  T H E   W A R   B E G I N S
--	   Stratagus - A free fantasy real time strategy game engine
--      bfm.lua - Defines
--
--      (c) Copyright 2005 by David Stone
--
--      This program is free software; you can redistribute it and/or modify
--      it under the terms of the GNU General Public License as published by
--      the Free Software Foundation; either version 2 of the License, or
--      (at your option) any later version.
--
--      This program is distributed in the hope that it will be useful,
--      but WITHOUT ANY WARRANTY; without even the implied warranty of
--      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
--      GNU General Public License for more details.
--
--      You should have received a copy of the GNU General Public License
--      along with this program; if not, write to the Free Software
--      Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------

DefineRaceNames(
	"race", {
		"name", "allies",
		"display", "Allies",
		"visible"},
    "race", {
		"name", "axis",
		"display", "Axis",
		"visible"},
	"race", {
		"name", "neutral",
		"display", "Neutral"})

DefineBoolFlags("capture", "fighter")

function DefineIcon(arg)
    icon = CIcon:New(arg.Name)
    icon.G = CGraphic:New(arg.File, arg.Size[1], arg.Size[2])
    icon.Frame = arg.Frame
end

--DefinePlayerColorIndex(10, 10)

DefineVariables("Level", "attack")


if (OldCreateUnit == nil) then
  OldCreateUnit = CreateUnit
  
  
    local t = {
    {"unit-ic", "unit-ic"},
	{"unit-inf", "unit-inf2"}
	}
	
  AlliesEquivalent = {}
  AxisEquivalent = {}

  for i=1,table.getn(t) do
    AlliesEquivalent[t[i][2]] = t[i][1]
    AxisEquivalent[t[i][1]] = t[i][2]
  end
end


-- Convert a unit type to the equivalent for a different race
function ConvertUnitType(unittype, race)
  local equiv

  if (race == "human") then
    equiv = AlliesEquivalent[unittype]
  else
    equiv = AxisEquivalent[unittype]
  end

if (equiv ~= nil) then
    return equiv
  else
    return unittype
end
end
